﻿using _1_Interfaces.Interfaces.Cjw;
using _1_Interfaces.Models.Dtos.Cjw;
using _1_Interfaces.Models.Tables.Cjw;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace _3_Controllers.Controllers.Cjw
{
    /// <summary>
    /// 聊天服务
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CjwChatListController : ControllerBase
    {
        private IChatListService _chatListService;
        public CjwChatListController(IChatListService chatListService)
        {
            _chatListService = chatListService;
        }

        /// <summary>
        /// 小程序发送消息
        /// </summary>
        /// <param name="userSendDto"></param>
        /// <returns></returns>
        [HttpPost]
        public bool UserSendMessage(UserSendDto userSendDto)
        {
            return _chatListService.UserSendMessage(userSendDto);
        }

        /// <summary>
        /// 医生收取消息
        /// </summary>
        /// <param name="docName">医生帐号</param>
        /// <param name="state">0 或者 1 没有全部 不会传全部的 全部不考虑</param>
        /// <param name="pageIndex">第几页</param>
        /// <param name="pageSize">一页几条</param>
        /// <returns></returns>
        [HttpGet]
        public ChatListDto DocGetMessage(string docName, int state, int pageIndex, int pageSize)
        {
            return _chatListService.DocGetMessage(docName, state, pageIndex, pageSize);
        }

        /// <summary>
        /// 医生发消息
        /// </summary>
        /// <param name="docSendDto"></param>
        /// <returns></returns>
        [HttpPost]
        public bool DocSendMessage(DocSendDto docSendDto)
        {
            return _chatListService.DocSendMessage(docSendDto);
        }

        /// <summary>
        /// 用户看医生回复
        /// </summary>
        /// <param name="openId ">openId</param>
        /// <returns></returns>
        [HttpGet]
        public List<ChatList> UserGetMessage(string openId)
        {
            return _chatListService.UserGetMessage(openId);
        }

        /// <summary>
        /// 用户评价
        /// </summary>
        /// <param name="userRateDto"></param>
        /// <returns></returns>
        [HttpPost]
        public bool UserRate(UserRateDto userRateDto)
        {
            return _chatListService.UserRate(userRateDto);
        }
    }
}
